package com.dave.gd.core.base.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.dave.gd.core.base.entity.IBaseEntityMeta;
import com.dave.gd.core.common.CUDTemplate;
import com.github.pagehelper.Page;

public interface BaseEntityMapper<T extends IBaseEntityMeta> {
    
    /**
     * 插入数据
     * 
     * @param obj
     */
    @InsertProvider(type = CUDTemplate.class, method = "insert")
    //    @SelectKey(before=false,keyProperty="id",resultType=long.class,statement="SELECT LAST_INSERT_ID() AS id")
    public void insert(T obj);
    
    /**
     * 更新数据
     * 
     * @param obj
     */
    @UpdateProvider(type = CUDTemplate.class, method = "update")
    public void update(T obj);
    
    /**
     * 删除数据
     * 
     * @param obj
     */
    @DeleteProvider(type = CUDTemplate.class, method = "delete")
    public void delete(T obj);
    
    /**
     * 获取数据
     * 
     * @param <E>
     * 
     * @param params
     * @return
     */
    @SelectProvider(type = CUDTemplate.class, method = "getObjectByMap")
    public Map<String, Object> getObjectByMap(Map<String, Object> params);
    
    /**
     * 获取数据列表
     * 
     * @param params
     * @return
     */
    @SelectProvider(type = CUDTemplate.class, method = "getObjectByMap")
    public List<Map<String, Object>> getObjectListByMap(Map<String, Object> params);
    
    /**
     * 获取分页数据
     * 
     * @param params
     * @return
     */
    @SelectProvider(type = CUDTemplate.class, method = "getObjectByMap")
    public Page<Map<String, Object>> getPageInfoByMap(Map<String, Object> params);
    
}
